package com.xiaoshuidi.cloud.module.finance.controller.admin.invoice;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.framework.security.core.LoginUser;
import com.xiaoshuidi.cloud.framework.security.core.util.SecurityFrameworkUtils;
import com.xiaoshuidi.cloud.module.finance.controller.admin.invoice.vo.FinanceInvoiceCompanyApplyReqVO;
import com.xiaoshuidi.cloud.module.finance.controller.admin.invoice.vo.InvoiceIssueReqVO;
import com.xiaoshuidi.cloud.module.finance.service.invoice.BaseInvoiceService;
import com.xiaoshuidi.cloud.module.finance.service.invoice.FinanceInvoiceRecordService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 企业开票
 */
@Tag(name = "管理后台 - 发票")
@RestController
@RequestMapping("/finance/base/invoice/company")
public class FinanceBaseInvoiceCompanyController {
    @Resource
    private BaseInvoiceService baseInvoiceService;

    @PostMapping("/apply")
    @Operation(summary = "企业开票")
    public CommonResult<String> companyApply(@Valid @RequestBody InvoiceIssueReqVO reqVO) {
        LoginUser user = SecurityFrameworkUtils.getLoginUser();
        return CommonResult.success(baseInvoiceService.issueInvoices(user,reqVO));
    }
}
